package com.java.day12.homework.homework1;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class CopyofArrShowUtils {
    public static List<ArtShow> createList() throws FileNotFoundException {
        //集合
        ArrayList<ArtShow> artShows = new ArrayList<>();
        //创建对象
//        ArtShow artShow = new ArtShow();
//        artShow.setShowName("唱歌");
//        artShow.setStuName("zjt");
//        artShow.setCount(2);
//        artShow.setStatus(1);
//
//        artShows.add(artShow);

        //Scanner对象
        //文件路径
        String s = "D:\\artshow.txt";
        File file = new File(s);
        Scanner scanner = new Scanner(file);
        while (scanner.hasNext()) {
            String line = scanner.nextLine();
            //解析字符串转换为ArtShow对象
            ArtShow artShow =  createArtShow(line);
            artShows.add(artShow);
        }

        scanner.close();
        return artShows;
    }

    private static ArtShow createArtShow(String line) {
        String s = "\t";
        String[] split = line.split(s);
        return new ArtShow(split[0],split[1],Integer.valueOf(split[2]),Integer.valueOf(split[3]));
    }

    public static void main(String[] args) throws FileNotFoundException {
        List<ArtShow> list = CopyofArrShowUtils.createList();
//        System.out.println(list);
        for (ArtShow artShow : list) {
            System.out.println(artShow);
        }
    }
}
